package com.example.back.controller.pay;

import com.example.back.bean.PayInfo;
import com.example.back.bean.YPayOrder;
import com.example.back.dao.pay.RechargeInfoDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;
import java.util.Map;

@RestController
public class WXPayInfo {
    @Autowired
    private RechargeInfoDao rechargeInfoDao;


    @RequestMapping(value = "all/pay")
    public List<YPayOrder> payInfo(int state) {
        if (state != -1) {
           return rechargeInfoDao.getPayStateRechargeInfoDao(state);
        }
        return rechargeInfoDao.getPayRechargeInfoDao();
    }

    @RequestMapping(value = "all/payByTime")
    public List<YPayOrder> payInfoByTime(Date startTime,Date endTime) {

        return rechargeInfoDao.getRechargeInfoDaoByTime(startTime,endTime);
    }

    @RequestMapping(value = "all/payState")
    public List<YPayOrder> payStateInfo(int state, long userId) {

        if (userId > 0) {
            return rechargeInfoDao.getOnePayStateInfoDao(state, userId);
        }
        return rechargeInfoDao.getPayStateInfoDao(state);
    }

    @RequestMapping(value = "all/money")
    public int paySuccessMoney() {

        return rechargeInfoDao.getPaySuccessMoney();
    }

    @RequestMapping(value = "all/getOneUser")
    public List<YPayOrder> getOneUserPayMoney(long userId, int state) {
        if (state != -1) {
            return rechargeInfoDao.getOneUserPayStateMoney(userId, state);
        }
        return rechargeInfoDao.getOneUserPayMoney(userId);
    }

    @RequestMapping(value = "all/oneUserMoney")
    public int getOneUserPayMoneyCount(long userId) {

        return rechargeInfoDao.getOneUserPayMoneyCount(userId);
    }

}
